﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace Dragon.Prototype1.Infrastructure.Controls
{
    public class Button:WebControl
    {
        protected override HtmlTextWriterTag TagKey
        {
            get
            {
                return HtmlTextWriterTag.Input;
            }
        }

        public string Text
        {
            get;
            set;
        }
        public bool CausesValidation
        {
            get;
            set;
        }
        public bool UseSubmitBehavior
        {
            get;
            set;
        }
        public string OnClientClick
        {
            get;
            set;
        }

        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            if (UseSubmitBehavior)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Type, "submit");
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Type, "button");
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Value, this.Text);
            if (this.Enabled&&!string.IsNullOrEmpty(this.OnClientClick))
            {
                writer.AddAttribute("onclick",this.OnClientClick);
            }

            base.AddAttributesToRender(writer);
        }
    }
}
